GIT reminder

Git global setup

Set user name :

git config --global user.name "Firstname Lastname"

Set user email :

git config --global user.email "[email protected]"

Create a new repository

git clone 
cd repo_folder
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Existing folder or Git repository

cd existing_folder
git init
git remote add origin 
git add .
git commit
git push -u origin master

Commit, pull and push

Update local version of the code :

git pull

Update code on repository :

git commit -a -m "Add a comment here"
git push origin master

Delete a file:

git rm filename

Discard local changes and get repository last version:

git checkout -- .

View list of servers

git remote -v

Create a new branch

git branch brancheName

Create a new branch from a previous commit

git branch brancheName commitName

List branch

git branch

Change branch

git checkout branchName

Create a new branch and switch to

git checkout -b branchName [commitName]

Merge current branch with master

git merge branchName

Push current branch to the server

git push origin branchName

Delete a branch

git branch -d branchName

Force to delete a branch

git branch -D branchName

Get last changes from master to the current branch

git pull master

or

git rebase

Commit one file

git add fileName
git commit -a -m "Comment"

Leave a Reply

Your email address will not be published. Required fields are marked *