A bit of git-ting

codes
git
push
pull
remote
local
2022

Create and delete repo

Author

Pratik Bhandari

Published

April 16, 2022


The first thing that I do for any data analyses or writing project is create a remote git repository either in github or in gitlab. Then I create a local R project in R Studio, and connect it to the remote git repo. The ‘how-to’ of this process can be found online; I’ll write up a brief overview, probably.

This post is to remind myself of most frequently used git commands.

The first thing I do for any data analyses or writing project is to create a remote git repository in github or gitlab. Then I create a local R project in R Studio and connect it to the remote git repo. I’ll probably write up a brief overview of this ‘how-to’ is some other post.

This post is to remind me of the most frequently used git commands.

Code
# Push local changes to the remote repo:
git push -u origin master

# Creat and checkout new branch:
git checkout -b NewBranchName

git push -u origin BranchIamWorkingOn # to push from local repo to remote repo if the remote repo doesn't have this `BranchIamWorkinOn` setup up already

# Delete a local branch:
git branch -D BranchToBeDeleted

Be careful about deleting. The -D is a hard delete!

Merge branches locally:

Code
git checkout main #First switch to the main/master branch
git merge BranchIwantToMerge #The branch still exists after merging

This was a dirty note down ;)

Other frequently used commands are git pull, git merge, git rm -r --cached, etc.

Tune in for notes on frequently used R, bash and git commands.