git branch
- the one with the
*
next to it is your currentHEAD
git branch -r
- repositories that are hosted on the repo will be preceded with
origin/
##Create and checkout branch (based off of remote)
git checkout development/3.8.0
Branch development/3.8.0 set up to track remote branch development/3.8.0 from origin. Switched to a new branch 'development/3.8.0'
What this will do is create and track based off of the remote branches.
git status
main points are Untracked files and Modified files
Untracked - Brand New files that haven't been on the repo ever. If you want to delete them, you simply delete them and they're gone.
Modified - Files that have already been added via git add
, and committed.
If you wish to revert a file to it's last committed state (applies to Modified files)
git checkout /path/to/file.ext
git push <REMOTENAME> <BRANCHNAME>
git push -u origin feature/my-new-feature
In the case you want to rename a branch on the remote
git push origin feature/my-new-feature:feature/my-renamed-feature
By default git wont set up tracking for you (so if others push to the same branch, you wont know about the changes)
to do so, add -u
git push -u origin feature/my-new-feature
git pull
git pull <REMOTENAME> <BRANCHNAME>
If you wish to pull your currently tracked branch:
git pull
If you wish to specify exactly which branch:
git pull origin development/3.8.0
git merge <BRANCHNAME>
Rule of thumb is you merge INTO your HEAD
.
For example, you ran git branch
development/3.8.0
* feature/my-feature
master
This would mean our HEAD
is our feature branch, feature/my-feature
.
Let's say we want to update development/3.8.0
with our feature branch
first, we would
git checkout development/3.8.0
git merge feature/myfeature
at this point, the merge is complete
now if we ran
git status
we will see:
Your branch is ahead of 'origin/development/3.8.0' by # commit.
now we can run
git push