Git Commands
This document serves as a reference to common Git commands. I keep forgetting them constantly
For first time setup only
Run the below lines in the terminal only during the initial setup Here ‘name’ represents the github username and ‘email’ represents your github email
$ git config –global user.name “[name]”
$ git config –global user.email “[email address]”
This command sets the author name and email address respectively to be used with your commits.
For regular workflows
All the commands are self explanatory
$ git init [repository name]
This command is used to start a new repository.
$ git clone [url]
Example : git clone https://github.com/Adithya1243/googleDataAnalytics_capstone.git
This command is used to obtain a repository from an existing URL.
$ git add *
This command adds one or more to the staging area.
$ git commit -m “[ Type in the commit message]”
This command records or snapshots the file permanently in the version history.
$ git status
This command lists all the files that have to be committed.
$ git branch
This command lists all the local branches in the current repository.
$ git push [variable name] [branch]
Example : git push origin default
origin -> URL of git repo – https://github.com/Adithya1243/googleDataAnalytics_capstone.git
default -> is the branch name
This command sends the branch commits to your remote repository.
Rare commands
Used little less frequently.
$ git commit -a
This command commits any files you’ve added with the git add command and also commits any files you’ve changed since then.
$ git rm [file]
This command deletes the file from your working directory and stages the deletion.
$ git log
This command is used to list the version history for the current branch.
$ git branch -d [branch name]
This command deletes the branch in github website.
$ git checkout [branch name]
This command is used to switch from one branch to another.
$ git merge [branch name]
This command merges the specified branch’s history into the current branch.
Special Errors
unable to push using git lfs. Increase file limit to 500MB. It should work
$ git config http.postBuffer 524288000
References
https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html