Contribute

Working with Repositories

Link anchorSetting up a Repository

Create a new local repository:

git init

Create a new repository out of a directory:

git init <directory>

Create a copy of an existing repository inside Container:

git clone /path/repository_name.git

Create a copy of an existing repository inside Container into an directory:

git clone /path/repository_name.git <directory>

Create a copy of an private repository inside Container:

git clone username@host:/path/repository_name.git

Link anchorSaving Changes

Stage all changes in a file for next commit:

git add <filename>

Stage all changes in a folder for next commit:

git add <foldername>

Add all files to staging:

git add *

Commit changes to head:

git commit -m "Commit message"

Commit all changes in the working directory:

git commit -a

Link anchorInspecting a Repository

List which files are staged, unstaged, and untracked:

git status

Display the entire commit history using the default formatting:

git log

Link anchorConnecting to a Remote Repository

Add the server to be able to push to it:

git remote add origin <server>

List all currently configured remote repositories:

git remote -v

Link anchorWorking with Branches

Create a new branch and switch to it:

git checkout -b <branchname>

Switch from one branch to another:

git checkout <branchname>

List all the branches in your repo, and also tell you what branch you're currently in:

git branch

Delete the feature branch:

git branch -d <branchname>

Push the branch to your remote repository, so others can use it:

git push origin <branchname>

Push all branches to your remote repository:

git push --all origin

Delete a branch on your remote repository:

git push origin :<branchname>

For example, if you want to push to your master branch, just use:

git push origin master

Link anchorUpdate the Remote Repository

Merge changes on the remote server to your Container:

git pull

Merge a different branch into your active branch:

git merge <branchname>

View all the merge conflicts

git diff