GIT information

Re: GIT information

Postby Bertram » 04 Dec 2012, 09:39

A link that could be useful for the git fighters around:
https://github.com/blog/1335-tidying-up ... l-requests
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: GIT information

Postby IkarusDowned » 22 Jan 2013, 02:07

a quick tip on how I keep my local "clone" setup to deal with this often complicated mess of rebase / squash / push

I always like to create a brand new branch for any changes I do. I keep a master branch that is synched just before I create a new branch with Bertram's master, by doing a
{l Code}: {l Select All Code}
git reset --hard
git pull upstream master

again, this is off master. I then push it back onto the remote github repo if i can
{l Code}: {l Select All Code}
git push origin master

then, I create a new branch for whatever I am working on. You can name it whatever you want. BTW you can name it the same as a previous branch that you aren't using anymore, read on to see why
so:
{l Code}: {l Select All Code}
git checkout -b some_branch

that will create the new branch locally, and swith to it.
So now, you do all your work and you commit and push happily to your origin (or not, your call). When you have something you are ready to push, you do the rebase / squash.

remember, we are still in branch "some_branch"
first, rebase with the upstream. This is to make sure you have the latest code that you can
{l Code}: {l Select All Code}
git pull --rebase upstream master

next, you squash your commits. now, the way I do this is I go and find the latest commit hash on Bertram's master.Since you have just rebased, your code should be at bertram's master + your commits on top. so lets say that the latest commit on Bertram's master is 'deadbeaf'.
doing a:
{l Code}: {l Select All Code}
git rebase -i deadbeaf

puts me in interactive mode for squashing, Here, I turn all BUT THE FIRST commit from 'pick' to 'squash' (or just 's' for short). and then i do change the first commit from 'pick' to 'reword'
You'll then go through the process of re-wording your commits. These days, I put a summary of changes and maybe some cautionary notes, etc in there.
once you're all done, you have one "big" commit. Push this to your remote branch

{l Code}: {l Select All Code}
git push origin some_branch

and then submit your pull request!
you'll have some possible changes and comments, etc. but, once you finish and the pull request is completed, you can either delete the remote branch from github website itself (just click on your closed request and scroll to the bottom) or you can do it from your command line like so:

{l Code}: {l Select All Code}
git checkout master
git branch -d some_branch
git push origin :some_branch

notice on the first checkout you don't add -b. this tells git not to create the branch.
IkarusDowned
 
Posts: 37
Joined: 12 Nov 2012, 06:01

Re: GIT information

Postby Bertram » 22 Jan 2013, 12:13

Made the topic sticky as for the useful info put in it. Thanks again Ikarus for putting this here, I simply didn't take the time to, yet.
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Who is online

Users browsing this forum: No registered users and 1 guest

cron