Git Commands

Git Tutorial

1. git add -u : add within the directory everything under version control
2. git commit -am "some message": add and commit
3. .gitignore : create the git ignore file
4. git config --global color.ui auto: get colored diff output
5. git remote add origin http://... (repo address created from github) : name remote as origin, and add remote to local git repository
6. git remote -v: v stands for verbose, this command will show the git repository where you fetch data from and push data to
7. git push origin master: push master branch to origin(origin is just the name of the remote you named)
8. git branch: check branch status
9. git branch branch_name: create a new branch
10. git checkout branch_name: change active branch to branch_name
11. git checkout c2744f95d
git checkout -b new-branch-name c2744f95d: create a new branch from the checkout point
12. git checkout -b branch_name: create a new branch and point HEAD to the new branch
13. git merge branch1: merge branch1 to current active branch
14. git merge branch1 branch2: merge branch1 into branch2
15. git branch –f master temp: update master to point to the new branch
16. git branch -d branch_name: delete a branch
17. git pull origin master: = git fetch origin + git merge master origin/master
provide username and password to git
18. git clone

19. git fetch origin
git reset --hard origin/master: fetch the latest history from the server and point your local master branch at it (drop all your local changes and commits)


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s