-
Notifications
You must be signed in to change notification settings - Fork 0
Home
GitFlow is a common way to use git. That is what we are using. It involves having two main branches:
- master
- develop
master
is for stable versions. When you have a stable version, one person (probly me) will be in charge of merging that to master
.
develop
is for combining your development chunks together on. Generally, this is also done by one person. They will take your branch and merge it in.
From develop
you will make new branches to work on. We generally call these feature
s and name them feature/whatever
. We have been bad about names, but that is what gitflow officially would take.
ok, enough intro, here is a flow for you:
git status
should read that you have no change
git checkout develop
to make sure you are on develop
git pull
to get the latest changes
git checkout -b [feature/name]
to make a new branch named [feature/name]
NOTE: branch name must be unique
--- do some work ---
git add -A
to add all your changes or git add [file] [file] ...
to add individual files git reset HEAD [file]
will "un-add" them before you commit
git status
to see what you are going to be committing (always one good last little check)
git commit -m "message"
commit with the message message
git status
at this point you should have no outstanding changes
git checkout develop
to get develop
git pull
to get latest changes into develop
git checkout [your branch name]
to go back to your branch
git merge develop
to merge develop into your branch
git status
there should be no files listed. If there are see merge section to get guidance on resolution
--- test that the merge was successful. If not, fix changes, commit them, and then move on once git status
is clean again ---
git push -u origin my_branch
to push your branch up to the remote server
--- Tell the person in charge of develop to merge your branch into it ---
git checkout develop
to go back to develop and start all over. Remember to pull, though!
If git status
does not say all is good after a commit, you will need to merge. This sets you in a merge state. You can cancel out and go back to just before you started the merge with git merge --abort
Right after attempting a merge, git status will show in green what files were ok. The unstaged-for-commit red files are ones with conflicts. These will need to be fixed and added. Then you can conclude the merge with a git commit -m "message"
just like you would regular changes. Changes other than the conflict resolution can be made to get things working. You should probly test things before you commit, too.
you will get sections in a file that look like this:
<<<<<<< HEAD:filename.txt
Here is some text that conflicts. This line is from the branch you are on.
=======
Here is some text that conflicts. This line is from the branch that you tried to merge in
Note that here vvvvvvvvv is the name of the branch or node you tried to merge in
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:filename.txt
these are the conflict sections. You can simply edit the file, remove the <<<<, =====, and >>>> lines and fix the conflict in the process. It is then ready to be staged to the commit with git add filename.txt
. You can use a smarter merge tool if you want. Meld is available online. I haven't used it, but I hear it is good.
You can also used the commands in the binary file section, if you want
you are kinda screwed and you are left with fewer choices
git checkout --ours [binary filename]
will give you the branch-you-are-on's version of [binary filename]
git checkout --theirs [binary filename]
will give you the branch-you-tried-to-merge-in's version of [binary filename]
once you have chosen who's version of the file you want for all the binary files, test things, then git add
those files.
If you are having issues with git lfs failing, you may need to disable smudge for a while then install it back in. Something like this:
// Skip smudge - We'll download binary files later in a faster batch
git lfs install --skip-smudge
// Do git clone here
git clone ...
// Fetch all the binary files in the new clone
git lfs pull
// Reinstate smudge
git lfs install --force