First things first, Try this git basics challenges @ try.github.io
--
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com $ git commit --amend --author="Author Name <email@address.com>" $ git branch -m old_branch new_branch //# Rename branch locally
$ git push origin :old_branch //# Delete the old branch
$ git push --set-upstream origin new_branch //# Push the new branch, set local branch to track the new remote If you follow the instructions in the Git message and pull:
$ git pull origin masterGit actually does the following two commands:
$ git fetch origin master
$ git merge origin/masterAnd the following happens to the commit tree:
C1 - C2 - C3 - C4 - C5 - C6 - C7 (master)
\ \
C5' - C6' - C7' - C8 (origin/master)On the other hand, if you are to rebase:
$ git fetch origin master
$ git rebase originThe following happens to the commit tree:
C1 - C2 - C3 - C4 - C5' - C6' - C7' - C5 - C6 - C7 (master)
|
(origin/master)Suppose you have four different commit, but you want to convert into single commit, Following example will helps to do.
You commits,
- List item
#1 01d1124 Adding license
#2 6340aaa Moving license into its own file
#3 ebfd367 Jekyll has become self-aware.
#4 30e0ccb Changed the tagline in the binary, too.$ git rebase -i HEAD~4
p 01d1124 Adding license
s 6340aaa Moving license into its own file
s ebfd367 Jekyll has become self-aware.
s 30e0ccb Changed the tagline in the binary, too.
# Rebase 60709da..30e0ccb onto 60709da
#
# Commands:
# p, pick = use commit
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#This may prompt you to do an confirmation for commit, once you successfully rebase you can push with -f(force).
This gist was got inspired by https://gist.github.com/lttlrck/9628955 | http://mattsnider.com/git-rebase-versus-git-pull/ | http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html