Last active
April 14, 2020 09:39
-
-
Save CallMarl/02a3f455a2888000fb15f8606184fb0b to your computer and use it in GitHub Desktop.
Git usual command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
email = PaHaGeek@gmail.com | |
name = CallMarl | |
[alias] | |
lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all | |
[core] | |
autocrlf = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add file from local repo | |
git add filename | |
git add -A | |
# Display changes | |
git status | |
git status -s | |
# Stage the changes | |
git commit -m "My comment" | |
# Change the last commit message | |
git commit --amend | |
# Change last commit files | |
git reset --soft HEAD~1 | |
# Unstage changes | |
git reset HEAD -- | |
git reset HEAD -- filename | |
# Rewind file | |
git checkout filname | |
# Display remote | |
git remote -v | |
# Create remote | |
git remote add remote_name url | |
# Set remote | |
git remote set-url url remote_name | |
# Push tu remote repo | |
git push remote_name branche_name | |
# Set remote repo as persistente destination | |
git push --set-upstream remote_name branch_name | |
git push -u remote_name branch_name | |
# Pushing when persistente destination is set | |
git push | |
# display branch | |
git branch -a | |
# display current branch name | |
git branch | |
# create new branch | |
git branch new_branch_name | |
git branch new_branch_name new_branch_name1 | |
# create new branch and swith to it | |
git checkout -b new_branch_name | |
# remove branch | |
git branch -d branch_name | |
git branch -d branch_name branch_name_1 | |
# switch between existing branch | |
git checkout branch_name | |
# display last commit | |
git log | |
# merge specific commit into the current branch | |
git cherry-pick commit_id | |
# merge branch to the current one | |
git merge branche_name | |
# return to old repo state | |
git checkout commit_id | |
# see differences between current state old commit | |
git diff commit_id | |
# See differences between 2 commit | |
git diff commit_id1 commit_id2 | |
# See differences between current branch and other one | |
git diff other_branch_name | |
# See differences between 2 branches | |
git diff branche1 branch2 | |
# Display tag | |
git tag | |
# Create tag | |
git tag -- tag_name | |
# Remove tag | |
git tag -d tag_name | |
# Create tag in specific commit | |
git checkout commit_id | |
git tag -- tag_name | |
# Go to tag state | |
git checkout tag_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Display submodue | |
git submodule | |
# Add submodule to the project | |
git submodule add url path_to_submodule | |
# Make sur the url is not private url https://CallMarl@github.com/my_private_repo | |
# Prefere public repo like https://github.com/my_public_repo with no username | |
# Install submodule | |
git submodule init | |
git submodule update | |
# For each submodule go to path then do following otherwise the commit will be in detached head state | |
git checkout master | |
# Update submodule | |
# go to submodule folder | |
# make sur you are attached to master | |
git checkout master | |
# download update | |
git pull | |
# go back to repo root folder then stage the changes | |
git add path_to_submodule | |
git commit "Updating submodule" | |
# Remove submodule | |
# Remove submodule in .gitmodule | |
# Also remove on local repo .git/config | |
git rm --cached path_to_submodule | |
# save change | |
rm -rf .git/module/path_to_submodule | |
git add .gitmodule path_to_submodule | |
git commit -m "Remove submodule" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment