sudo apt-get install git
-
Create repository on GitHub without initializing with README file.
-
navigate to the directory and initialize:
git init
-
Add the files in local repository and stages them for commit:
git add .
-
commit the files:
git commit -m "First commit"
-
add the URL:
git remote add origin https://github.com/username/myproject.git
-
verify the new URL:
git remote -v
-
push changes:
git push origin master
-
Add the files in local repository and stages them for commit:
git add .
-
commit the files:
git commit -m "current commit"
-
push changes:
git push origin master
-
git pull
is a convenient shortcut for completing bothgit fetch
andgit merge
in the same commandIf you run into a merge conflict you cannot resolve, or if you decide to quit the merge, you can use
git merge --abort
to take the branch back to where it was in before you pulled. -
Force to overwrite local files:
git fetch --all
git reset --hard origin/master
git pull origin master
-
set Git username for every repository on your computer:
git config --global user.name "YourUserName"
Setting your Git username for a single repository:
git config user.name "YourUserName"
check username:
git config user.name
-
set your email address for every repository on your computer
git config --global user.email "[email protected]"
Setting your email address for a single repository:
git config user.email "[email protected]"
check email address:
git config user.email
Turn on the credential helper so that Git will save your password in memory for some time. By default, Git will cache your password for 15 minutes.
-
Set git to use the credential memory cache:
git config --global credential.helper cache
-
Set the cache to timeout after 1 hour (setting is in seconds):
git config --global credential.helper 'cache --timeout=3600'
Reset the head to the number of commits back by 2 for example:
git reset --hard HEAD~2
and force pushed using:
git push -f origin master
-
Delete file or folder:
git rm -r file-name.txt or folder
thengit commit -m "Remove file or folder"
-
Check status:
git status
-
Update combo:
git add * && git commit -m "something" && git push origin master