git:git-branches
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
git:git-branches [2023/03/31 12:17] – created - external edit 127.0.0.1 | git:git-branches [2023/10/31 11:51] (current) – [Working with multiple branches] admin | ||
---|---|---|---|
Line 4: | Line 4: | ||
===== Main commands ===== | ===== Main commands ===== | ||
- | |||
To create a new branch, e;g called **devel**, do: | To create a new branch, e;g called **devel**, do: | ||
Line 31: | Line 30: | ||
**Important note** : if you checkout from one branch to another, you will lose all the not committed changes in the branch you leave. | **Important note** : if you checkout from one branch to another, you will lose all the not committed changes in the branch you leave. | ||
+ | |||
+ | ===== Pull/push from/to specific remote branch ===== | ||
+ | |||
+ | Tu pull a branch on remote that does not exist locally, we first create an empty local branch, then we pull by setting the right origin. For example for a remote branch **new_branch** : | ||
+ | <code bash> | ||
+ | git checkout -b new_branch | ||
+ | git pull origin new_branch | ||
+ | </ | ||
+ | |||
+ | Tu push a local branch to remote, we use **--set-upstream** : | ||
+ | <code bash> | ||
+ | git push --set-upstream origin new_branch | ||
+ | </ | ||
===== Working with multiple branches ===== | ===== Working with multiple branches ===== | ||
Line 45: | Line 57: | ||
To get all the differences between branch **b1** and **b2**, do : | To get all the differences between branch **b1** and **b2**, do : | ||
<code bash> | <code bash> | ||
- | $ git diff master..foxy | + | $ git diff b1..b2 |
</ | </ | ||
To only see the files that have change , out can type : | To only see the files that have change , out can type : | ||
<code bash> | <code bash> | ||
- | $ git diff master..foxy | grep "diff --git" | + | $ git diff b1..b2 | grep "diff --git" |
</ | </ | ||
To see the changes on a single file **file1.txt** : | To see the changes on a single file **file1.txt** : | ||
<code bash> | <code bash> | ||
- | git diff master..foxy file1.txt | + | git diff b1..b2 file1.txt |
</ | </ | ||
git/git-branches.1680257844.txt.gz · Last modified: 2023/03/31 12:17 by 127.0.0.1