GitHub Basics - ashBabu/Utilities GitHub Wiki
git tag -a v1.0.0 -m "Working version of Ouster lidar and realsense-rtabmap slam
-
git tag
# to view the tags -
git push --tags
# to push all the tags - `git push v1.0.01 # to push the specific tag
-
cd
to the directory git submodule add -b branch_name https:....url/of/the/repo
sudo nano ~/.ssh/config
And add the following
Host github.com
Hostname ssh.github.com
Port 443
To change the base of a branch here
lets say branch current
has base branch named old_base
. To change the base to a branch named new_base
,
git checkout current
git rebase --onto new_base old_base current
git branch -r | grep -v '\->' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
# just for completeness
git pull --all
git fetch origin --prune
# will delete all the branches locally that are deleted from remote
git merge --no-ff branch_name
# will have all the commit histories
-
git stash pop
# to get back the stashed -
git stash drop
# to remove the stashed
*. First commit the changes on the current branch
*. git fetch 'branch_name'
*. git merge upstream/branch_name
*. If needed push the changes
To pull all submodules here
git submodule update --init --recursive
OR
git submodule init
git submodule update
git rev-parse HEAD
# To get the latest commit id
git revert {commit_id}'
git push origin/upstream branch/master
From here
-
Make note of the PR number.
-
Fetch the PR's pseudo-branch (or bookmark or rev pointer whatever the word is), and give it a local branch name. Here we'll name it
pr37
:$ git fetch upstream pull/37/head:pr37
-
Switch to that branch:
$ git checkout pr37
-
Compile and test.
If the PR code changes and you want to update:
# Do this while in the pr37 branch
$ git pull upstream pull/37/head
Merging the PR
You can use the Github web interface, but there's a TOCTOU problem: If the pull-requester changes their master (or whatever they're PRing from) between the time you test and the time you merge, then you'll be merging code that you haven't reviewed/tested. So let's do it on the command line.
First, checkout the upstream master code:
You'll only do this the first time -- it creates the local upstream_master
branch, tracks it to upstream_master
, and switches to the branch:
$ git checkout -t -b upstream_master upstream/master
After the first time you'll just do:
$ git checkout upstream_master
Now merge the PR:
$ git merge pr37
NOTE: You should edit the merge commit message to reference the PR (using, say #37
in it).
Now push:
$ git push upstream HEAD:master
(You can't just git push
because your local branch name is different than the remote.)
Done! Refresh the Github PR page and you'll see that the PR is now merged+closed.
git fetch upstream
git checkout master
git rebase upstream/master
or git merge upstream/master
git push origin master
sudo apt-get install git
-
sudo apt-get install git gui
# for graphical user interface (if needed) git config --local (or --global) user.name "yourGithubName"
git config --local (or --global) user.email "yourGithubEmail"
git clone https://github.com/ashbabu/MixedReality.git
git branch branch_name
git branch
git checkout branch_name
Work on the files in the branch. If file1 needs to be added to the remote
git add file1
git commit -m 'your short msg about the changes made to file1'
-
git push origin branch_name
# to make it available in the branch of your repo
If a commit is made and later on if you want to undo the commit, git rm --cached name_of_file
git rm file1.txt
git commit -m "remove file1.txt"
To remove the file only from the Git repository and not remove it from the filesystem, use:
git rm --cached file1.txt
git commit -m "remove file1.txt"
git merge origin master <branch_name>
# merges the branch with master
git push origin <branch_name>
git branch --delete <remote_name> <branch_name>
ex: git push origin --delete test
git branch --delete <branch>
git branch -d <branch>
# Shorter version
git branch -D <branch>
# Force delete un-merged branches
-
Go to github.com and use fork button to fork the desired repository (orig_repo) to add to your local repositories (local_repo)
-
git clone https:github.com/../local_repo.git
Clone the local_repo to your PC. -
git remote add upstream https:github.com/.../orig_repo.git
-
git fetch --all
-
git checkout -b _name_of_ur_branch_
-
Make changes to the code and commit it
-
git push origin _name_of_ur_branch_
-
Make pull request to upstream master (on github)
-
Wait for it to be merged
-
git checkout master
-
git pull upstream/master
-
Go to step 5
git checkout master
git pull origin master
-
git merge test
# test is the name of the branch git push origin master