Blog Post
Git Commands
August 11, 2020
A basic guide to regular Git commands I always forget…
To clone a remote repo:
Navigate to local folder
Clone remote repo
git clone {URL}
When making changes:
- Make local changes
- Add changes to staging area
git add -A
- Commit changes to local repo
git commit -m "message"
- Pull/Push to remote repo
(to make sure no one has updated remote repo) THEN…git pull origin master
git push origin master
Working with branches:
Create a branch
git branch [name of branch]
Checkout branch
git checkout [name of branch]
add, commit change to local branch
git add -A
THEN
git commit -m "message"
commit push branch to remote
git push -u origin [name of branch]
(just first time to push it to remote and link the two together)
in the future… you can just use
git push
To merge…
- Switch to master change
git checkout master
- Pull from master to make sure we’re up to date
git pull origin master
- Merge branch
git merge [name of branch]
- Push to remote
git push origin master
- Check to see which things have been merged into master
git branch --merged
To delete branch
- Check to make sure it’s merged (should show merged branch)
git branch --merged
- Delete local branch
git branch -d [branch name]
- Delete remote branch
git push origin --delete [name of remote branch]
- Check everything
git branch -a
(double check all local and remote branches are deleted)