- To start your first local git repository:
- Initialise the repository
git init
- Add all the files in the current directory
git add .
- Commit your initial import
git commit
- Initialise the repository
- To monitor changes and logs in your code:
- View the revision history
git log
- View the file changes in the repository
git diff
- View the changes for a specific revision and file/directory path
git diff revision path
- Summary of the current changes to the repository
git status
- Some house cleaning functions:
- To add a file:
git add file
- To remove a file:
git rm file
- To move a file:
git mv file
- To remove all untracked files (such as temporary files used during compilation):
git clean
- Configure your git instance
- Change your username
git config --global user.name "Your Name"
- Change your email
git config --global user.email email@domain.com
- Common functions
- Clone an existing repository
git clone url
- Fetch the changes from remote master repository
git fetch
- Similar to above, but this command will merge the changes as well
git pull
- Push your changes to a remote repository
git push url
- Commit all your changes to the local repository
git commit -a
- Edit your last commit with latest changes
git commit --append
- Toss away your last commit
git reset HEAD^
- Assign blame for problematic files
git blame file
- Tags and branches
- Tags a version
git tag -a name
- List tags
git tag -l
- Show the details about a tag
git show tag
- Create a new branch
git branch branch
- Switch to a branch
git checkout branch
- Delete a branch
git branch -d branch
- List all branches
git branch
- Merges a branch to our current working branch
git merge branch
http://schacon.github.com/git/gittutorial.html
http://gitref.org
No comments:
Post a Comment
Thanks for contributing!! Try to keep on topic and please avoid flame wars!!