Skip to content

datascibox/github_reference

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github_reference

A collection of useful GitHub commands and procedures




Sections




Pull and fetch & merge changes

[back to top]


Automatic pull for subdirectories

[back to top]

Shell command to pull changes from the remote for all subdirectories in the current directory.

find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \;

For your convenience - since the syntax may not be easy to remember - you can put this command into a shell script and save it into your main GitHub directory to conveniently pull all changes for all your contained GitHub repositories via

sh pull_all.sh


Force to overwrite local files

[back to top]

Replace local changes with most recent contents from HEAD.

git checkout -- <file>

Fetches the most recent files from the remote and resets the master branch to those by overwriting all local changes.

git fetch --all
git reset --hard origin/master


Connecting to GitHub and GitLab

[back to top]



####Connecting to GitHub and GitLab servers via SSH

[back to top]

If you want to communicate to the GitHub/GitLab servers via a "more secure" connections or if your are using a terminal that doesn't support https.



Branching

[back to top]



Branching Basics

[back to top]

Create a new branch called "develop"

git branch develop

Switch to new branch

git checkout develop

Alternative shorthand for creating and switching:

git checkout -b develop

Delete the branch

git branch -d develop

Push branch to the remote server:

git push origin develop

Preview differences between branches

git diff <source_branch> <target_branch>

Merge changes from new branch back into the master branch

git checkout master
git merge develop


Committing Changes

[back to top]



Committing Basics

[back to top]

Add individual files

git add <file>

Recursively add everything in the current directory

git add .

Commit changes

git commit -m 'some commit message'

Shorthand for adding all files and committing them in 1 command

git commit -a -m 'some commit message'


Remove files from commit

[back to top]

Removes staged (added files from the commit)

git rm --cached <file>

About

A collection of useful GitHub commands and procedures

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%