There's a lot going on, but it's not that complicated (honest).
git fetch upstream
git checkout master
git ff upstream/master # ffum
git push origin master # pom
git checkout back_to_branch
git checkout master
git checkout -b featureA
Clear in the Network where branches are, how many commits they contain, easily look at the diff of that commit/branch.
git checkout master
git checkout -b featureA
git fetch upstream
git checkout master
git ff upstream/master # ff = merge --ff-only
git checkout -b featureA
git checkout featureA
git status
git diff
git add -A
git add myfile.py myotherfile.py
git reset myotherfile.py
git commit -m "A short commit message"
git commit
git push origin featureA
git fetch upstream
git checkout master
git ff upstream/master # ffum
git push origin master
git checkout master
git checkout -b feature_branch
# do stuff
git commit
git push origin feature_branch
# PULL REQUEST VIA GITHUB
This means there are merge conflicts.
Update branch with rebase
git checkout featureA
# optionally, create backup branch:
git branch featureA_backup
git rebase master
# resolve merge conflicts (git add and git rebase --continue)
# retest and check functionality is still here!
git push origin feature_branch --force
git checkout featureA
# optionally, create backup branch
git branch featureA_backup
git rebase -i HEAD~N # N is number of commits to squash
# this opens a file: replace all but the first pick with s
# then opens the commit message (usually you can leave as is)
git diff featureA_backup # optionally, compare with the backup
# this diff this should be blank (otherwise you've dropped a commit*)
git push origin featureA --force # this updates the PULL REQUEST
# you took a backup right?
git checkout featureA_backup # go to the branch
git branch -D featureA # hard delete the unsuccessful branch
git checkout -b featureA # create branch with the same name
# back where we started, try rebase -i again
git checkout pr/1234
git rebase master
Eventually you’ll discover the Easter egg in Git: all meaningful operations can be expressed in terms of the rebase command. Once you figure that out it all makes sense. I thought the joke would be obvious: rebase, freebase, as in what was Linus smoking? -- Linus Torvalds
git push --force origin featureA
git rebase --interactive HEAD~N
Check it out on your project's Github page.
VS
Significantly easier to spot mistakes in the process:
git checkout pr/1234
The True Meaning Of Pain.
[color]
ui = true
[alias]
r = rebase
f = fetch
ff = merge --ff-only
co = checkout
c = commit
a = add
d = diff
p = push
pull = pull --rebase # but don't use pull
s = status
h = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
po = push origin
rum = rebase upstream/master
fu = fetch upstream
ffum = merge --ff-only upstream/master
dum = !git diff $(git merge-base upstream/master HEAD)
[remote "upstream"]
fetch = +refs/heads/*:refs/remotes/upstream/*
fetch = +refs/pull/*/head:refs/remotes/upstream/pr/*
git remote show upstream
git remote add betty https://github.com/bettys_username/project.git
git fetch betty
git remote set-url origin https://github.com/your_username/project.git
git remote set-url --push origin no_push