Add a personal file (which is not pushed) with a commit, perhaps?

I have this question because it would be very helpful in cases like this: I am currently working on an open source program and I would like the git repository to be clean, containing only the source and assembly files. However, I also wrote a few scripts that are only relevant to me but are quite related to a commit or a branch I'm working on.

Is it possible to keep those files with a commit but not pushed to the remote repo?

+3


source to share


4 answers


Either way, you are working in your separate repo and branch. This way you can transfer your utility files along with the corresponding chahegs. When you prepare a commit for a pull request, just create a separate checkout branch, check it out, and remove those files in the next commit. Your development branch will still have these files in older commits.

when the function is ready: create a branch and checkout in it

git checkout -b pull_request
git rm <all utility files>
git commit -am'removed utility files'

      



you can also do this with a single commit to keep the history tidy. After the previous commands:

git reset --soft <sha1 where I forked this branch>
git commit -am'implemented feature X'

      

Now your pull_request branch contains all the changes from the last commit and does NOT contain your utility files in any of the commits you make in the middle.

+1


source


Not easy if you don't want to push the file, it can't be in the commit (a branch is just a pointer to the commit). The hash commit is created among others from the file tree it contains, so dropping the file will change the hash and break syncing with the remote repo.



You can have these files in another repo and use a script to switch branches to both at the same time.

0


source


How about they are on your working tree as unreported changes!
Add them to your .git / info / exclude file so they don't show up in status.

You never do them, and with this extension you never push them! However, you can keep a separate copy of your scripts (perhaps the git repo itself) so you don't accidentally delete them from your work line. (Git will never touch them if they are untracked).

0


source


One solution is to have a private github folder (not a pretty solution).

0


source







All Articles