Git Commands : -
git clone <repository address> //clone the repository to local system
git checkout -b <branch name> //switch branch
git branch -a // list all the branches
git remote -v
git config --list // check config file
git status //working branch details
git add <filename> //add file to git local
git commit -m "message" //commit on local system
git log // show all log of commit
git pull // pull always before push.
git push origin <branch name> // push code to git
git difftool cid1 cid2 // diffrence on files , cid - commitid
git checkout --filename // remove change from file
git checkout -- . // remove changes from all file
git revert commitid // revert changes from that commit and commit the changes
git revert -m commitid // revert changes from that commit but not commit the changes
git reset --hard commitid // move to commitid code
git branch branchname //create new branch
git checkout -b branchname //create new branch, seccond will create branch and will also checkout
git merge b //suppose we are in branch a , so merging b to a
//add files to git
git add -A // it will add files from all directory
git add -A "directoryname" // (git add "directory")only this directorys file will be added
git add --no-all "directory name" //
git add --ignore- "directory name"
git add . //add all the files to stash from current directory
git add * // misterius
//creating branch
git branch <branchname> // create branch
git checkout <branchname> // checkout branch
git checkout branch <branchname> // create branch and checkout branch together - (git checkout -b feature/SPW-626)
git push -u origin <branchname> // push branch to remote - (git push -u origin feature/SPW-626)
git branch -d <branchname> // delete branch
git push origin --delete <branchname> // delete branch from remote
//rename branch //https://linuxize.com/post/how-to-rename-local-and-remote-git-branch/
git checkout <old_name>
git branch -m <new_name>
git push origin -u <new_name>
git push origin --delete <old_name>
//correct mistakes
git commit --amend -m "correct message" //override previous commit wrong message, in this case hash(history) will also change
git log --stat //show all the files that has changed to current commit
git cherry-pic <commit id>// get commit from different branch
// delete latest commit
git reset --soft <commit id> // remove last commit but changes will be available in staging area
git reset <commit id> // its simmiler to soft, in this also file can be in working directory or staging area
git reset --hard <commit id> // remove last changes but keep untracked file
git clean -df // clean untracked file(f) and directory(d)
git reflog //history of commits
git revert <commit id> //create a new commit with the requird changes
git diff <commitid 1> < commitid 2> //compare two commit changes
//stash
git stash save "comment" // will remove the current changes but will keep them
git stash list // list all the stashed
git stash apply "stashid" // will apply all the changes from the stash id but the id will not be deleted from stash list
git stash pop // will pop the top stashed id and delete the stash
git stash drop "stash id" // this will drop the stash id
git stash clear // will delete all the stash from list
git show head //show head commit
git show commitid // its also to see commit
git clone <repository address> //clone the repository to local system
git checkout -b <branch name> //switch branch
git branch -a // list all the branches
git remote -v
git config --list // check config file
git status //working branch details
git add <filename> //add file to git local
git commit -m "message" //commit on local system
git log // show all log of commit
git pull // pull always before push.
git push origin <branch name> // push code to git
git difftool cid1 cid2 // diffrence on files , cid - commitid
git checkout --filename // remove change from file
git checkout -- . // remove changes from all file
git revert commitid // revert changes from that commit and commit the changes
git revert -m commitid // revert changes from that commit but not commit the changes
git reset --hard commitid // move to commitid code
git branch branchname //create new branch
git checkout -b branchname //create new branch, seccond will create branch and will also checkout
git merge b //suppose we are in branch a , so merging b to a
//add files to git
git add -A // it will add files from all directory
git add -A "directoryname" // (git add "directory")only this directorys file will be added
git add --no-all "directory name" //
git add --ignore- "directory name"
git add . //add all the files to stash from current directory
git add * // misterius
//creating branch
git branch <branchname> // create branch
git checkout <branchname> // checkout branch
git checkout branch <branchname> // create branch and checkout branch together - (git checkout -b feature/SPW-626)
git push -u origin <branchname> // push branch to remote - (git push -u origin feature/SPW-626)
git branch -d <branchname> // delete branch
git push origin --delete <branchname> // delete branch from remote
//rename branch //https://linuxize.com/post/how-to-rename-local-and-remote-git-branch/
git checkout <old_name>
git branch -m <new_name>
git push origin -u <new_name>
git push origin --delete <old_name>
//correct mistakes
git commit --amend -m "correct message" //override previous commit wrong message, in this case hash(history) will also change
git log --stat //show all the files that has changed to current commit
git cherry-pic <commit id>// get commit from different branch
// delete latest commit
git reset --soft <commit id> // remove last commit but changes will be available in staging area
git reset <commit id> // its simmiler to soft, in this also file can be in working directory or staging area
git reset --hard <commit id> // remove last changes but keep untracked file
git clean -df // clean untracked file(f) and directory(d)
git reflog //history of commits
git revert <commit id> //create a new commit with the requird changes
git diff <commitid 1> < commitid 2> //compare two commit changes
//stash
git stash save "comment" // will remove the current changes but will keep them
git stash list // list all the stashed
git stash apply "stashid" // will apply all the changes from the stash id but the id will not be deleted from stash list
git stash pop // will pop the top stashed id and delete the stash
git stash drop "stash id" // this will drop the stash id
git stash clear // will delete all the stash from list
git show head //show head commit
git show commitid // its also to see commit
Tags:
Dev