Add your Git username and set your email
It is important to configure your Git username and email address, since every Git commit will use this information to identify you as the author.
git config --global user.name "YOUR_USERNAME" git config --global user.email "[email protected]"
Create and Switch to a new branch
git checkout -b NAME-OF-BRANCH
Download the latest changes in the project
To sync with other users’ changes on the branch, while keep what you have changed locally, use:
git pull REMOTE NAME-OF-BRANCH
where REMOTE will typicall be your
View diff against other branch
while under your current branch:
git diff NAME-OF-BRANCH
Add all changes to commit
git add . git commit -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
git add -A
. character typically means all in Git.
Delete all changes in the Git repository
To delete all local changes in the repository that have not been added to the staging area, and leave unstaged files/folders, type:
git checkout .
Unstage all changes that have been added to the staging area
To undo the most recent add, but not committed, files/folders:
git reset .
Merge created branch with master branch
E.g: under current non master branch
git checkout NAME-OF-BRANCH git merge master
Delete all change history in a git
Deleting the .git folder may cause problems in your git repository. If you want to delete all your commit history but keep the code in its current state, it is very safe to do it as in the following:
#Checkout git checkout --orphan latest_branch #Add all the files git add -A #Commit the changes git commit -am "commit message" #Delete the branch git branch -D master #Rename the current branch to master git branch -m master #Finally, force update your repository git push -f origin master
PS: this will not keep your old commit history around
Tags can be retrieved by:
git fetch --tags
and to switch to a tagged branch:
git checkout tags/1.1.4
Note: if use
git checkout 1.1.4 it may also work if there’s no branch called
After sucessfull fetch, you can make changes and then
checkout -b a new branch and commit push.