This wiki is a starting point to teach new git
users how to use such a powerful tool. We will write here every useful command, from cloning to tag checkout. If you find something missing, as usual, add it by yourself.
Even if the majority of us is "pro-shell" and "pro-keyboard", some are way more used to GUIS an mouse interactions. And beautiful things.
Don't worry guys, GitHub & Atlassian have heard our prayers :
- GitHub app : This is the best app when you start using git. Even if it has been made for GitHub repositories, it can manage your local repositories and has most of the useful git commands built in its core. Download it for mac / for windows. Notice : As it has been made for Github, you will have to clone your repository locally with a terminal, then add it in the app like a local repository.
- Source Tree : Way more complete (and complexe) than Github app, Source Tree is simply the best git UI app. You can do everything you would with your terminal, with some clicks, drags and drops. Download it here.
Here are the common steps when you want to create a new project :
-
First, check that you added your ssh key into your profile : https://github.com/settings/keys
-
Create your repository (as internal) : https://github.com/new
-
Then go to your workspace folder, and clone it :
git clone git@github.com:{your_username}/{your_project}.git
-
Go to your folder :
cd {your_project}
-
Now create a README.md file :
touch README.md
-
Add some infos inside, and add it to the tracked files :
git add README.md
-
If you do a
git status
now, you'll be able to see that your file is now tracked in your next commit -
Then, commit your changes with a message :
git commit -m "Init repo"
-
And push your changes :
git push origin master
And you're done ! Your nightmare is over.
-
Create a new branch :
Generate it :
git checkout -b {your_branch_name}
Publish it on remote :
git push origin {your_branch_name}
-
List all branches :
git branch -a
-
Add missing files/changes to your last commit :
Revert commit :
git reset --soft HEAD~1
Add your files :
git add ...
Reapply commit :
git commit -c ORIG_HEAD
-
Checkout unstaged modifications :
single file:
git checkout <file_path>
all files:
git checkout -- .
-
Remove a file from ALL your repository history (e.g sensitive data) :
git filter-branch --index-filter \
'git rm -r --cached --ignore-unmatch {your_file_or_directory}' HEAD
-
Rename a tag :
git tag new old
git tag -d old
git push origin :refs/tags/old
git push --tags