Git my own cheatsheet


#create a new local git repo
git clone https://github.com/nowardev/testagain.git
#create a new file 
echo hello> file1.txt
#add a file to a commit 
git add file1.txt
#do the first commit 
git commit -a -m 'my first commit'
#push the commit to master remote (github for example)
git push origin master
#create a new branch
git checkout -b mynewbranch
#do some work in some file
echo hellobranch >file2.txt
#add the file2.txt to a commit
git add file2.txt
#do the commit locally 
git commit -a -m 'my commit locally'
#push the commit to remote branch 
git push origin mynewbranch
#print the branch 
git branch
#back to master locally
git checkout master
#merge the branch wit master
git merge mynewbranch
#now push the merge on remote
git push origin master 
#delete the branch cuz you have merged it
git branch -d mynewbranch 
#delete the branch on remote 
git push origin --delete mynewbranch
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: