Skip to content

Notes on using Git

Eric Taucher edited this page Jul 13, 2013 · 5 revisions

How to create a branch with current changes?

Create a branch using

git checkout -b new_branch_name

When new_branch_name is created, you can commit and push as you do with master branch.

git add <files>
git commit ...
git push ...

For more detailed explanation, see this answer.

====

How to pull and overwrite local files.

Sometimes you make changes to the local files but then want to pull down the latest changes from a repository, i.e. master, using

git pull origin master

without saving your local changes. Git knows you made changes and will not allow this with a warning like:

error: Your local changes to the following files would be overwritten by merge:  
        <file(s)>  
Please, commit your changes or stash them before you can merge.  
Aborting  

To force an overwite use:

git reset --hard HEAD  
git pull origin master

===

###msysGit vs Git for Windows

Some of refer to using mysysGit and some of refer to using Git for Windows, why two different Git clients?

If one checks msysGit vs Git for Windows it notes:

• msysGit is the msys+mingw environment + everything needed to compile git yourself, on Windows.  
• Git for Windows is exactly that: git, compiled for Windows.  

===

###Git GUI and Git Bash

If one installs mysysGit from the start button one gets Git GUI and Git Bash.

So if you prefer to use a GUI instead of a command line as I do for Git then you can use the GUI. Note: There are many things that you cannot do with the GUI but for many common task it works just fine.

=== ###Merge branch 'master' of github.com:jack-pappas/NHol

If one looks at the commits this comes up occasionally.

My understanding of this is that previous person did a push without running 'git pull origin master' just before doing their previous push. So the repository becomes out of sync for the next person doing a push and this indicates that the conflict was resolved before the next push was accepted.