Remote
Save all your git history to a remote (Github, Gitlab, ...)
List
List every remotes or branches
Info
List every remote available
Info
List every remote branches available
Create
The template is : git remote add <remote_name> <adress>
Warning
Untracked changes are not stashed
Always use git status
first
Info
Untracked changes are also stashed !
Clone
The template is : git clone <remote_link> <local_name>
Info
Clone repository in a 'sound-play' folder
Info
Clone repository in a 'custom_name' folder
Warning
Only keep the last 5 commits in local history
Push
The template is : git push <remote_name> <local_branch_name>
Best practice to use remote_name = origin for the main remote
(it's Github default for ex)
Pull
The template is : git pull <remote_name> <remote_branch_name>
Warning
Might create a "Merge branch" commit if local is ahead of remote
Use rebase to avoid that
Rename
Info
Now the remote name is 'lol' instead of 'origin'
You can use git remote -v
to see that
Git clone someone else's repository & Git push to your own repository
-
Create a new repository at github.com. (this is your repository) Give it the same name as the other repository. Don't initialize it with a README, .gitignore, or license.
-
Clone the other repository to your local machine. (if you haven't done so already)
git clone https://github.com/other-account/other-repository.git
-
Rename the local repository's current 'origin' to 'upstream'.
git remote rename origin upstream
-
Give the local repository an 'origin' that points to your repository.
git remote add origin https://github.com/your-account/your-repository.git
-
Push the local repository to your repository on github.
git push origin master
-
Create a new repository at github.com. (this is your repository) Give it the same name as the other repository. Don't initialize it with a README, .gitignore, or license.
-
Clone the other repository to your local machine. (if you haven't done so already)
git clone https://github.com/other-account/other-repository.git
-
Change the local repository's current 'origin' to a new url.
git remote set-url origin http://github.com/YOU/YOUR_REPO
-
Push the local repository to your repository on github.
git push origin master