Here are some useful commands for git that we use on regular basis:
$ git status
— Status of the current branch
$ git log
— Commit history of the current branch
$ git add.
— Add all files for the push-in remote.
$ git commit -m “message”
— Replicate the same branch and set message[-m] as per required.
$ git push HEAD
— Always push the head of the current branch
$ git push origin <branch name>
— Send changes to remote
$ git pull
— Get remote changes to the current branch and merge.
$ git merge <branch name>
— Merges the provided branch with the current branch.
$ git branch <branch name>
— Create a new branch locally.
$ git branch -d
— Delete branch.
$ git fetch
— Fetch all remote changes and update project
$ git stash
— Clear remote changes
$ git stash pop
— Bring back(undo) stashed changes
$ git checkout <branch name>
— Switch from the current branch to another branch.
$ git checkout -b [yourbranchname]
— Switch from the current branch to another branch by creating them.
$ git init
— Initializes a new Git repository.
$ git clone
— Download existing code from any remote repository.
$ git branch
— List all the local branches of the project.
$ git reset — — hard
— Reset the current branch head with the remote.
Tips:
If you cant push from your mac using CLI:
https://stackoverflow.com/a/68921750/10994132
- Go to your Github
Settings
->Developer Settings
->Personal Access Tokens
page in GitHub (https://github.com/settings/tokens/new), and generate a new Token with all Repo permissions - Search Keychain Access in your mac -> search for
github.com
-> clickShow password
then paste thetoken
you just copied. - Go to the CLI, it will ask again for username and password, enter your Github username and paste the token as password, and you should be good to go for the rest of the times you are using the CLI.
If these git commands are helpful for your everyday job, please let me know. Tell me which commands you and your team use the most.
#happycoding #dev #mobile #tech #softwareeninner